home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / Direct3D / EnhancedMesh / EnhancedMesh.fx < prev    next >
Encoding:
Text File  |  2004-09-27  |  1.9 KB  |  64 lines

  1. //--------------------------------------------------------------------------------------
  2. // File: EnhancedMesh.fx
  3. //
  4. // The effect file for the EnhancedMesh sample.  
  5. // 
  6. // Copyright (c) Microsoft Corporation. All rights reserved.
  7. //--------------------------------------------------------------------------------------
  8.  
  9.  
  10. //--------------------------------------------------------------------------------------
  11. // Global variables
  12. //--------------------------------------------------------------------------------------
  13. float     g_fTime;                    // App's time in seconds
  14. float4   g_vDiffuse;                // Material diffuse color
  15. float4x4 g_mWorld;                    // World matrix for object
  16. float4x4 g_mWorldViewProjection;    // World * View * Projection matrix
  17. texture  g_txScene;
  18.  
  19.  
  20. sampler g_samScene =
  21. sampler_state
  22. {
  23.     Texture = <g_txScene>;
  24.     MinFilter = Linear;
  25.     MagFilter = Linear;
  26.     MipFilter = Linear;
  27. };
  28.  
  29.  
  30. void VertScene( float4 Pos : POSITION,
  31.                 float3 Normal : NORMAL,
  32.                 float2 Tex : TEXCOORD0,
  33.                 out float4 oPos : POSITION,
  34.                 out float2 oTex : TEXCOORD0,
  35.                 out float4 Diffuse : COLOR0 )
  36. {
  37.     oPos = mul( Pos, g_mWorldViewProjection );
  38.  
  39.     float3 N = normalize( mul( Normal, (float3x3)g_mWorld ) );
  40.     Diffuse = saturate( dot( (float3)N, float3( 0.0f, 0.0f, -1.0f ) ) ) * g_vDiffuse;
  41.  
  42.     oTex = Tex;
  43. }
  44.  
  45.  
  46. float4 PixScene( float2 Tex : TEXCOORD0,
  47.                  float4 Diffuse : COLOR0 ) : COLOR0
  48. {
  49.     return tex2D( g_samScene, Tex ) * Diffuse;
  50. }
  51.                 
  52.  
  53. //--------------------------------------------------------------------------------------
  54. // Techniques
  55. //--------------------------------------------------------------------------------------
  56. technique RenderScene
  57. {
  58.     pass P0
  59.     {
  60.         VertexShader = compile vs_1_1 VertScene();
  61.         PixelShader = compile ps_1_1 PixScene();
  62.     }
  63. }
  64.